import React from "react";

import * as UI from "antd-mobile";

import * as Router from "react-router-dom";

import * as Icons from 'antd-mobile-icons'

import Request from "@/services/request";

import Cookies from 'react-cookies';

React.UI = UI;

React.Router = Router;

React.Icons = Icons;

React.Http = Request;

React.Cookies = Cookies;



React.toast = (msg: string, callback?: any, type?: string) => 
    {
        React.UI.Toast.show({
            icon: type ? type : 'success',
            content: msg,
            duration: 1500,
            afterClose: () => 
            {
                if(!callback) return;
    
                if(typeof callback === "string")
                {
                    callback === "back" ? React.navigate(-1) : React.navigate(callback)
                }else{
                    callback();
                }
            }
        })
    }

    React.RouterRules = [
        '/',
        '/coupon/info',
        '/business/login',
        '/room/info'
    ]

    export default {};